# distutils: sources = wdtw_impl.c
# distutils: language = c
import numpy as np
cimport numpy as np
from libc.math cimport pow, fmin

cdef extern from "wdtw.h":
    double wdtw(const double *x, int n,
                const double *y, int m,
                const double *weight_vec,
                double sakoe_band,
                double alpha)

def wdtw_c(np.ndarray[np.double_t, ndim=1] x,
            np.ndarray[np.double_t, ndim=1] y,
            np.ndarray[np.double_t, ndim=1] weight_vec,
            double sakoe_band = float('inf'),
            double alpha=1.0):
    """
    Python 接口：计算两条序列的 WDTW 距离
    sakoe_band 支持 float('inf') 表示无约束
    """
    cdef int band
    if sakoe_band == float('inf'):
        band = -1
    else: 
        band = <int>sakoe_band

    cdef double dist
    dist = wdtw(&x[0], x.shape[0], &y[0], y.shape[0], &weight_vec[0], band, alpha)
    return dist